﻿
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>公告管理</title>
    <#include "../common/link.ftl">
    <script>
        $(function () {
            //console.log(3);
            $(".btn-input").click(function () {

                //清楚数据
                $("#editForm input").val('');
                /*var id = $(this).attr("id");
                var name = $(this).attr("name");
                var sn = $(this).attr("sn");
                console.log(sn);
                console.log(id);*/
                var json = $(this).data("json");
                //console.log(json);

                //回显
                if(json){
                    $("input[name=id]").val(json.id);

                    $("input[name=title]").val(json.title);

                    $("textarea[name=content]").val(json.content);
                    $("input[name='seller.id']").val(json.sellerId);
                }

                //弹出模态框
                $('#editModal').modal('show');
            })


            $(".btn-submit").click(function () {
                var params = $('#editForm').serialize();
                $.post('/notice/saveOrUpdate',params,handlerMessage)
            })


            $(".btn-delete").click(function () {
                var id = $(this).data('id');
                $.messager.confirm('警告','是否确认删除',function () {
                    //发送异步请求
                    $.get('/notice/delete?id='+id,handlerMessage)
                })
            })

        })
        
        
    </script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#--<c:set var="currentMenu" value="notice"/>-->
    <#assign currentMenu="notice"/>
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>公告管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <a href="#" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>公告标题</th>
                            <th>发布人</th>
                            <th>发布时间</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        <#--<c:forEach items="${pageResult.result}" var="notice" varStatus="vs">-->
                            <#list pageResult.list as notice>
                                <tr>
                                    <td>${notice_index+1}</td>
                                    <td>${notice.title!}</td>
                                    <td>${notice.issuer.name!}</td>
                                    <td>${(notice.pubdate?string('yyyy-MM-dd'))!}</td>
                                    <td>${notice.readed ? string("已读","未读")}</td>
                                    <td>
                                        <a href="/notice/see?id=${notice.id}&readed=${notice.readed ? string("true","false")}"
                                           class="btn btn-info btn-xs btn-see">
                                            <span class="glyphicon glyphicon-tags"></span> 查看
                                        </a>
                                        <a href="#" data-json='${notice.json}'
                                           class="btn btn-info btn-xs btn-input">
                                            <span class="glyphicon glyphicon-pencil"></span> 编辑
                                        </a>
                                        <a href="#" data-id="${notice.id}" class="btn btn-danger btn-xs btn-delete">
                                            <span class="glyphicon glyphicon-trash"></span> 删除
                                        </a>
                                    </td>
                                </tr>

                            </#list>


                        <#--</c:forEach>-->
                    </table>
                    <!--分页-->
                    <#include "../common/page.ftl">
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>

<#--模态框-->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">新增/编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal"  method="post" id="editForm">
                    <input type="hidden" name="id" >
                    <input type="hidden" name="seller.id" >
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-3 control-label">标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="title" name="title"
                                   placeholder="请输入公告标题">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-3 control-label">内容：</label>
                        <div class="col-sm-6">
                            <textarea class="form-control" id="content" name="content"
                                      placeholder="请输入公告内容"></textarea>
                        </div>
                    </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary btn-submit">保存</button>
            </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>
